/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author roycalderon
 */
@Entity
@Table(name = "bookList")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "BookList.findAll", query = "SELECT b FROM BookList b"),
    @NamedQuery(name = "BookList.findByIdbookList", query = "SELECT b FROM BookList b WHERE b.bookListPK.idbookList = :idbookList"),
    @NamedQuery(name = "BookList.findByBookBorrowingidbookBorrowing", query = "SELECT b FROM BookList b WHERE b.bookListPK.bookBorrowingidbookBorrowing = :bookBorrowingidbookBorrowing"),
    @NamedQuery(name = "BookList.findByBookBorrowingEmployeeidEmployee", query = "SELECT b FROM BookList b WHERE b.bookListPK.bookBorrowingEmployeeidEmployee = :bookBorrowingEmployeeidEmployee"),
    @NamedQuery(name = "BookList.findByBookBorrowingStudentidStudent", query = "SELECT b FROM BookList b WHERE b.bookListPK.bookBorrowingStudentidStudent = :bookBorrowingStudentidStudent")})
public class BookList implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected BookListPK bookListPK;
    @JoinColumns({
        @JoinColumn(name = "Book_idBook", referencedColumnName = "idBook"),
        @JoinColumn(name = "Book_bookType_idbookType", referencedColumnName = "bookType_idbookType"),
        @JoinColumn(name = "Book_Editorial_idEditorial", referencedColumnName = "Editorial_idEditorial"),
        @JoinColumn(name = "Book_knowledgeArea_idknowledgeArea", referencedColumnName = "knowledgeArea_idknowledgeArea")})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Book book;
    @JoinColumn(name = "bookReception_idbookReception", referencedColumnName = "idbookReception")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private BookReception bookReceptionidbookReception;
    @JoinColumn(name = "bookBorrowing_idbookBorrowing", referencedColumnName = "idbookBorrowing", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private BookBorrowing bookBorrowing;

    public BookList() {
    }

    public BookList(BookListPK bookListPK) {
        this.bookListPK = bookListPK;
    }

    public BookList(int idbookList, int bookBorrowingidbookBorrowing, int bookBorrowingEmployeeidEmployee, int bookBorrowingStudentidStudent) {
        this.bookListPK = new BookListPK(idbookList, bookBorrowingidbookBorrowing, bookBorrowingEmployeeidEmployee, bookBorrowingStudentidStudent);
    }

    public BookListPK getBookListPK() {
        return bookListPK;
    }

    public void setBookListPK(BookListPK bookListPK) {
        this.bookListPK = bookListPK;
    }

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public BookReception getBookReceptionidbookReception() {
        return bookReceptionidbookReception;
    }

    public void setBookReceptionidbookReception(BookReception bookReceptionidbookReception) {
        this.bookReceptionidbookReception = bookReceptionidbookReception;
    }

    public BookBorrowing getBookBorrowing() {
        return bookBorrowing;
    }

    public void setBookBorrowing(BookBorrowing bookBorrowing) {
        this.bookBorrowing = bookBorrowing;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (bookListPK != null ? bookListPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BookList)) {
            return false;
        }
        BookList other = (BookList) object;
        if ((this.bookListPK == null && other.bookListPK != null) || (this.bookListPK != null && !this.bookListPK.equals(other.bookListPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.BookList[ bookListPK=" + bookListPK + " ]";
    }
    
}
